using micromsg;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Network;
using MicroMsg.Protocol;
using MicroMsg.Scene;
using MicroMsg.Storage;
using System;
using System.Collections.Generic;
namespace MicroMsg.Plugin.Shake.Scene
{
	public class NetSceneShakeGet : NetSceneBaseEx<ShakeGetRequest, ShakeGetResponse, ShakeGetRequest.Builder>
	{
		private const string TAG = "NetSceneShakeGet";
		public bool doScene(SKBuiltinBuffer_t skbuiltinBuffer_t_0)
		{
			Log.smethod_4("NetSceneShakeGet", "doscene in");
			base.beginBuilder();
			this.mBuilder.BaseRequest = NetSceneBase.makeBaseRequest(0);
			this.mBuilder.Buffer = skbuiltinBuffer_t_0;
			this.mBuilder.IsNewVerson = 1;
			this.mSessionPack.mCmdID = 57;
			base.endBuilder();
			return true;
		}
		protected override void onFailed(ShakeGetRequest request, ShakeGetResponse response)
		{
			PackResult lastError = base.getLastError();
			Log.smethod_4("NetSceneShakeGet", "onFailed in PackResult =" + lastError);
			if (lastError == PackResult.BEEN_CANCELLED)
			{
				return;
			}
			EventCenter.postEvent(EventConst.ON_NETSCENE_SHAKE_ERR, null, null);
		}
		protected override void onSuccess(ShakeGetRequest request, ShakeGetResponse response)
		{
			Log.smethod_4("NetSceneShakeGet", "onSuccess in");
			RetConst ret = (RetConst)response.BaseResponse.Ret;
			if (ret != RetConst.MM_OK)
			{
				EventCenter.postEvent(EventConst.ON_NETSCENE_SHAKE_ERR, null, null);
				return;
			}
			List<ShakePeople> param = this.procShakeList(response.ShakeGetListList);
			EventCenter.postEvent(EventConst.ON_NETSCENE_SHAKE_SUCCESS, param, null);
		}
		private List<ShakePeople> procShakeList(IList<ShakeGetItem> srcList)
		{
			List<ShakePeople> list = new List<ShakePeople>();
			double nowMilliseconds = Util.getNowMilliseconds();
			int num = 0;
			using (IEnumerator<ShakeGetItem> enumerator = srcList.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					ShakeGetItem current = enumerator.get_Current();
					list.Add(new ShakePeople
					{
						strProvince = Util.NullAsNil(current.Province),
						strCity = Util.NullAsNil(current.City),
						strSignature = Util.NullAsNil(current.Signature),
						strDistance = Util.NullAsNil(current.Distance),
						strNickName = Util.NullAsNil(current.NickName),
						strUserName = Util.NullAsNil(current.UserName),
						nSex = current.Sex,
						bHasImg = current.ImgStatus != 4u,
						bHasHDImg = current.HasHDImg != 0u,
						NumDistance = (int)current.NumDistance,
						strWeibo = Util.NullAsNil(current.Weibo),
						strWeiboNickName = Util.NullAsNil(current.WeiboNickname),
						nWeiBoFlag = (int)current.WeiboFlag,
						nVerifyFlag = (int)current.VerifyFlag,
						strVerifyInfo = Util.NullAsNil(current.VerifyInfo),
						strVerifyContent = Util.NullAsNil(current.VerifyContent),
						nSnsFlag = current.SnsUserInfo.SnsFlag,
						strSnsBGImgID = current.SnsUserInfo.SnsBGImgID,
						nSnsBGObjectID = current.SnsUserInfo.SnsBGObjectID,
						nHeadImgVersion = current.HeadImgVersion,
						dblTimeStamp = nowMilliseconds + (double)num++,
						strMyBrandList = current.MyBrandList,
						nBrandFlag = current.CustomizedInfo.BrandFlag,
						strBrandExternalInfo = current.CustomizedInfo.ExternalInfo,
						strBrandInfo = current.CustomizedInfo.BrandInfo,
						strBrandIconURL = current.CustomizedInfo.BrandIconURL
					});
				}
			}
			return list;
		}
	}
}
